<?php

function list_yearly_income(){

//PASANG JAVASCRIPT
my_set_code_js('

function confirmDelete(id){
	var t = confirm(\'Yakin akan menghapus data ?\');
	if(t){
		location.href=\'index.php?com=yearly_income&task=delete&id=\'+id;
	}
	return false;
}

');
	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Uraian'=>array('style'=>'border-bottom:2px solid;width:535px'),    
		' '=>array('style'=>'border-bottom:2px solid;width:50px'), 
	);

	$query = "SELECT * FROM yearly_income  ORDER BY yearly_income_id ASC";
	$result = my_query($query);
	$i = 0;
	$row=array();
	while($ey = my_fetch_array($result)){
		$i++;
		$editproperty = array(
				'href'=>'index.php?com=yearly_income&task=edityearly_income&id='.$ey['yearly_income_id'],
				'rel'=>'facebox',
				'title'=>'Edit'
		);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );

		$detailproperty = array(
				'href'=>'index.php?com=yearly_income&task=list_yearly_group&yearly_income_id='.$ey['yearly_income_id'],
				'title'=>'Komponen'
		);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  );
		
		$deleteproperty = array(
				'href'=>'javascript:; ',
				'onclick'=>'javascript:confirmDelete('.$ey['yearly_income_id'].');',
				'title'=>'Delete'
		);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		 
		$row[] = array(
			'#'=>position_text_align ($i, 'center'),  
			'm'=>  $ey['label']  ,    
			'operasi'=> position_text_align(  $edit_button.' '.$detail_button.' '.$delete_button , 'right'),  
		);
		 
	}
	
	$datas = table_rows($row);  
	$menuontop = array(  
		'Tambah data'=>array('onclick'=>'javascript:jQuery.facebox({ ajax: \'index.php?com=yearly_income&task=edityearly_income&id=0\' })'),
		//'Export to excel'=>array('onclick'=>'javascript:location.href=\'index.php?com=csv&task=excel_daftar_karyawan\''),
		'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=all_yearly_income\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');')
	); 
	$printmenu = additional_menu_on_list( $menuontop ,'');
	return  table_builder($header , $datas ,  3 , false );
}

function form_yearly_income_validate($id){
	$errsubmit = false;
	$err = array();
	 
	$code =  trim($_POST["label"]); 
	if( $code == ''){
		$errsubmit = true;
		$err[] ="Nama belum diisi";
	}
	
	$query="SELECT yearly_income_id FROM yearly_income 
		WHERE label='".$code.
		"' AND yearly_income_id<>".$id; 
	if (my_num_rows( my_query($query)) >0){
		$errsubmit = true;
		$err[] = "Nama sudah digunakan";
	}
	
	if( $errsubmit){
		return $err;
	}
	return $errsubmit;
}

function form_yearly_income_submit($id){
	$datas = array( 
		'label'=>my_type_data_str( $_POST['label'] ),  
	);
	if($id > 0){
		return my_update_record('yearly_income' ,'yearly_income_id' , $id , $datas);
	}
	
	return my_insert_record('yearly_income' , $datas);
}

function form_yearly_income_create($id = 0){
	$view = form_header( "yearly_income" , "yearly_income"  );
 	$fields = my_get_data_by_id('yearly_income','yearly_income_id',$id);

	$label = array(
		'name'=>'label',
		'value'=>( isset($_POST['label']) ? $_POST['label'] : $fields['label'] ),
		'id'=>'label',
		'type'=>'label',
		'size'=>'45'
	);
	$form_field_major = form_dynamic($label);
	
	$view .= form_field_display( $form_field_major  , "Nama"  );   
	 
	$submit = array(
		'value' => ( $id ==0 ? ' Simpan ' :'  Update  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 
	
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
} 

function remove_yearly_income($id){
	$query= "DELETE FROM yearly_income WHERE yearly_income_id = {$id}";
	return my_query($query);
} 
 

/*  
==================================================================
2. YEARLY GROUP
==================================================================
*/ 
function list_yearly_group($yearly_income_id){
	my_set_code_js('
		function confirmDelete(id){
			var t = confirm(\'Yakin akan menghapus data ?\');
			if(t){
				location.href=\'index.php?com='.$_GET['com'].'&task=yearly_group_delete&id=\'+id;
			}
			return false;
		}
	');
	
 	$header = array(
		'Nomor'=>array('style'=>'border-bottom:2px solid;width:15%'),    
		'Uraian Judul'=>array('style'=>'border-bottom:2px solid;width:30%'),    
		'Uraian Total'=>array('style'=>'border-bottom:2px solid;width:30%'),    
		'Kategori'=>array('style'=>'border-bottom:2px solid;width:15%'),    
		' '=>array('style'=>'border-bottom:2px solid;width:10%'), 
	);
 
	$query = "SELECT * FROM yearly_group WHERE yearly_income_id ={$yearly_income_id} ORDER BY code";
 	$result = my_query($query);
	$row=array();
	while($ey = my_fetch_array($result)){
		$editproperty = array(
			'href'=>'index.php?com=yearly_income&task=create_yearly_group&yearly_income_id='.$yearly_income_id.'&id='.$ey['yearly_group_id'],
			'rel'=>'facebox',
			'title'=>'Edit'
		);

		$edit_button = button_icon( 'b_edit.png' , $editproperty  );

		$detailproperty = array(
			'href'=>'index.php?com=yearly_income&task=list_komponen&yearly_income_id='.$yearly_income_id.'&yearly_group_id='.$ey['yearly_group_id'],
			'title'=>'Komponen'
		);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  ) ;
		
		$deleteproperty = array(
			'href'=>'javascript:;',
			'title'=>'Delete',
			'onclick'=>'confirmDelete('.$ey['yearly_group_id'].')',
		);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );		
	
		$row[] = array(
			'code'=>  $ey['code'] ,    
			'label'=>  $ey['label'] ,    
			'uraian_total'=>  $ey['uraian_total'] ,    
			'kategori'=>  $ey['kategori'] ,    
			'operasi'=> position_text_align(  $edit_button.' ' .$detail_button.' '.$delete_button, 'right'),  
		);
		 
	}
	$datas = table_rows($row); 
	$yearly_incomes = my_get_data_by_id('yearly_income','yearly_income_id',$yearly_income_id); 	 
	$view ='<table width="90%" cellspacing="0" cellpadding="4"><tr>'; 
	$view .= form_header( "a" , "a"  );
	$view .= form_field_display( '<span class="label_form">'.ucfirst($yearly_incomes['label']).'</span>', "<b>Yearly Income</b>"    ); 
	return  $view. table_builder($header , $datas ,  3 , false );
}

function form_yearly_group_create($yearly_income_id, $id = 0){
	$view = form_header( "yearly_group" , "yearly_group"  );
 	$fields = my_get_data_by_id('yearly_group','yearly_group_id',$id);
 	$yearly_incomes = my_get_data_by_id('yearly_income','yearly_income_id',$yearly_income_id); 	 

	$temp = array(
		'name'=>'code',
		'value'=>( isset($_POST['code']) ? $_POST['code'] : $fields['code'] ),
		'id'=>'code',
		'type'=>'text',
		'size'=>'10'
	);
	$form_temp = form_dynamic($temp);
	$view .= form_field_display( $form_temp   , "Kode");
	
	$temp = array(
		'name'=>'label',
		'value'=>( isset($_POST['label']) ? $_POST['label'] : $fields['label'] ),
		'id'=>'label',
		'type'=>'text',
		'size'=>'45'
	);
	$form_temp = form_dynamic($temp);
	$view .= form_field_display( $form_temp   , "Uraian");

	$temp = array(
		'name'=>'uraian_total',
		'value'=>( isset($_POST['uraian_total']) ? $_POST['uraian_total'] : $fields['uraian_total'] ),
		'id'=>'uraian_total',
		'type'=>'text',
		'size'=>'45'
	);
	$form_temp = form_dynamic($temp);
	$view .= form_field_display( $form_temp   , "Uraian Total");

	$datas = array(
		'+'=>'+',
		'-'=>'-',
	);
	$temp = array(
		'name'=>'kategori',
		'id'=>'kategori',
		'value'=>isset($_POST['kategori']) ? $_POST['kategori'] : $fields['kategori'],
	);
	$form_temp = form_dropdown($temp , $datas);
	$view .= form_field_display( $form_temp , "Kategori" );

	$submit = array(
		'value' => ( $id ==0 ? ' Simpan ' :'  Update  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
} 
	 
function form_yearly_group_submit($yearly_income_id , $id =0){
	$datas = array(
		'yearly_income_id'=>my_type_data_int($yearly_income_id),	
		'code'=>my_type_data_str( $_POST['code'] ),
		'label'=>my_type_data_str( $_POST['label'] ),	
		'uraian_total'=>my_type_data_str( $_POST['uraian_total'] ),	
		'kategori'=>my_type_data_str( $_POST['kategori'] ),	
	);
	
	if($id > 0){
		return my_update_record('yearly_group' ,'yearly_group_id' , $id , $datas);
	}
	return my_insert_record('yearly_group' , $datas);
} 

function form_yearly_group_validate($yearly_income_id , $id =0){
	$errsubmit = false;
	$err = array();
	 
	$nama =  trim($_POST["label"]); 
	if( $nama == ''){
		$errsubmit = true;
		$err[] = "Uraian belum diisi";
	}

	$query="SELECT yearly_group_id FROM yearly_group 
		WHERE label='".$nama.
		"' AND yearly_income_id=".$yearly_income_id.
		" AND yearly_group_id<>".$id; 
	if (my_num_rows( my_query($query)) >0){
		$errsubmit = true;
		$err[] = "Nama sudah ada";	
	}
    
	if( $errsubmit){
		return $err;
	}
	return $errsubmit;
}

function delete_yearly_group($id){
	$query = "DELETE FROM yearly_group WHERE yearly_group_id ={$id} ";
	return my_query($query);
}	
 

/*  
==================================================================
3. KOMPONEN
==================================================================
*/
 function list_komponen($yearly_income_id,$yearly_group_id){
	my_set_code_js('
		function confirmDelete(id){
			var t = confirm(\'Yakin akan menghapus data ?\');
			if(t){
				location.href=\'index.php?com='.$_GET['com'].'&task=komponen_delete&id=\'+id;
			}
			return false;
		}
	');
	
 	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:5%'),  
		'Nama Komponen'=>array('style'=>'border-bottom:2px solid;width:25%'),    
		'Dasar Nilai'=>array('style'=>'border-bottom:2px solid;width:55%'),    
		'Pajak'=>array('style'=>'border-bottom:2px solid;width:5%'),    
		' '=>array('style'=>'border-bottom:2px solid;width:10%'), 
	);
 
	$query = "SELECT * FROM yearly_komponen WHERE yearly_group_id ={$yearly_group_id}";
 	$result = my_query($query);
	$i = 0;
	$row=array();
	while($ey = my_fetch_array($result)){
		$i++;
		$editproperty = array(
				'href'=>'index.php?com=yearly_income&task=create_komponen&yearly_group_id='.$yearly_group_id.'&id='.$ey['yearly_komponen_id'],
				'rel'=>'facebox',
				'title'=>'Edit'
		);

		$edit_button = button_icon( 'b_edit.png' , $editproperty  );

		$deleteproperty = array(
			'href'=>'javascript:;',
			'title'=>'Delete',
			'onclick'=>'confirmDelete('.$ey['yearly_komponen_id'].')',
		);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );		

		$datas_model_entry = array(
			'1'=>'Gaji Pokok',
			'2'=>'Komponen Gaji',
			'3'=>'Nilai Pajak',
			'4'=>'Upload',
			'5'=>'Selisih Pembulatan',
			'6'=>'Total',
		);
		
		$dasar_nilai=$datas_model_entry[$ey['model_entry']] ;
		if( (int) $ey['komponen_gaji_id'] >0 ){
		
		}
	
		$row[] = array(
			'#'=>position_text_align ($i, 'center'), 
			'nama'=>  $ey['nama_komponen'] ,    
			'dasar'=> $dasar_nilai ,    
			'pajak'=>  $ey['kena_pajak'] ,    
			'operasi'=> position_text_align(  $edit_button.' '.$delete_button, 'right'),  
		);
		 
	}
	$datas = table_rows($row); 
	$yearly_groups = my_get_data_by_id('yearly_group','yearly_group_id',$yearly_group_id); 
	$yearly_incomes = my_get_data_by_id('yearly_income','yearly_income_id',$yearly_income_id); 	 
	$view ='<table width="90%" cellspacing="0" cellpadding="4"><tr>'; 
	$view .= form_header( "a" , "a"  );
	$view .= form_field_display( '<span class="label_form">'.ucfirst($yearly_incomes['label']).'</span>', "<b>Yearly Income</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$yearly_groups['code'].'. '.$yearly_groups['label'].'</span>', "<b>Kelompok</b>"    ); 
	return  $view. table_builder($header , $datas ,  3 , false );
}

function form_komponen_create($yearly_income_id,$yearly_group_id, $id = 0){
	$view = form_header( "komponen" , "komponen"  );
 	$fields = my_get_data_by_id('yearly_komponen','yearly_komponen_id',$id);
	$temp = array(
				'name'=>'nama_komponen',
				'value'=>( isset($_POST['nama_komponen']) ? $_POST['nama_komponen'] : $fields['nama_komponen'] ),
				'id'=>'nama_komponen',
				'type'=>'text',
				'size'=>'45'
			);
	$form_temp = form_dynamic($temp);
	$view .= form_field_display( $form_temp   , "Nama Komponen");

	$datas_model_entry = array(
		'1'=>'Gaji Pokok',
		'2'=>'Komponen Gaji',
		'3'=>'Nilai Pajak',
		'4'=>'Upload',
		'5'=>'Selisih Pembulatan',
		'6'=>'Total',
	);
	
	
	$temp = array(
		'name'=>'model_entry',
		'id'=>'model_entry',
		'value'=>isset($_POST['model_entry']) ? $_POST['model_entry'] : $fields['model_entry'] 
	);
	$form_temp = form_dropdown($temp , $datas_model_entry);	
	$view .= form_field_display( $form_temp , "Dasar Nilai" );
	
	$datas = array();
	$query_golongan = "SELECT * FROM pr_komponen_gaji ORDER BY komponen_gaji_id";
	$re = my_query($query_golongan);
	while($row = my_fetch_array($re) ){
		$datas[$row['komponen_gaji_id']] =$row['nama_komponen_gaji'];
	}
	$temp = array(
		'name'=>'komponen_gaji_id',
		'id'=>'komponen_gaji_id',
		'value'=>isset($_POST['komponen_gaji_id']) ? $_POST['komponen_gaji_id'] : $fields['komponen_gaji_id'],
	);
	$form_temp = form_dropdown($temp , $datas);
	$view .= form_field_display( $form_temp , "Komponen Gaji" );
	
	$c = array(
		'name'=>'formula',
		'value'=>( isset($_POST['formula']) ? $_POST['formula'] : $fields['formula'] ),
		'id'=>'formula',  
		'rows'=>'3',
		'size'=>'45',
		'onchange'=>'javascript:testFormula()'
	);
	$form_field_nama = form_textarea($c);
	$view .= form_field_display( $form_field_nama   , "Formula");

	
	
	
	 $jurnal = array();
	 $query_jurnal = "SELECT * FROM jurnal_gaji order by nama_jurnal_gaji";
	 $re = my_query($query_jurnal);
	 while($row = my_fetch_array($re) ){
		$jurnal[$row['jurnal_gaji_id']] =$row['nama_jurnal_gaji'].' ('.$row['kode_jurnal_gaji'].')';
	 }
	 $jurnal_gaji_id = array(
		'name'=>'jurnal_gaji_id',
		'id'=>'jurnal_gaji_id',
		'value'=>isset($_POST['jurnal_gaji_id']) ? $_POST['jurnal_gaji_id'] : $fields['jurnal_gaji_id'] 
	);
	$form_model_jurnal = form_dropdown($jurnal_gaji_id , $jurnal);
	$view .= form_field_display( $form_model_jurnal  , "Jurnal Gaji" ); 
	
	$datas = array(
		'Y'=>'Y',
		'T'=>'T',
	);
	$temp = array(
		'name'=>'kena_pajak',
		'id'=>'kena_pajak',
		'value'=>isset($_POST['kena_pajak']) ? $_POST['kena_pajak'] : $fields['kena_pajak'],
	);
	$form_temp = form_dropdown($temp , $datas);
	$view .= form_field_display( $form_temp , "Perhitungan Pajak" );

	 $temps = array();
	 $query_pajak = "SELECT * FROM pr_komponen_pajak 
		WHERE komponen_pajak_id < 7
		OR komponen_pajak_id = 8 
		OR komponen_pajak_id = 12";
	 $re = my_query($query_pajak);
	 while($row = my_fetch_array($re) ){
		$temps[$row['komponen_pajak_id']] =substr($row['label_pajak'], 0, 50);
	 }
	 
	 $temp = array(
		'name'=>'komponen_pajak_1',
		'id'=>'komponen_pajak_1',
		'value'=>isset($_POST['komponen_pajak_1']) ? $_POST['komponen_pajak_1'] : $fields['komponen_pajak_1'] ,
		'size'=>'35'
	);
	$form_temp = form_dropdown($temp , $temps); 
	$view .= form_field_display( $form_temp , "Komponen Pajak 1" );
	
	$temp = array(
		'name'=>'komponen_pajak_2',
		'id'=>'komponen_pajak_2',
		'value'=>isset($_POST['komponen_pajak_2']) ? $_POST['komponen_pajak_2'] : $fields['komponen_pajak_2'] ,
		'size'=>'35'
	);
	$form_temp = form_dropdown($temp , $temps); 
	$view .= form_field_display( $form_temp , "Komponen Pajak 2 ");

	$submit = array(
		'value' => ( $id ==0 ? ' Simpan ' :'  Update  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
} 
	 
function form_komponen_submit($yearly_income_id,$yearly_group_id , $id =0){
	$datas = array(
		'yearly_group_id'=>my_type_data_int($yearly_group_id),	
		'nama_komponen'=>my_type_data_str( $_POST['nama_komponen'] ),
		'model_entry'=>my_type_data_int( $_POST['model_entry'] ),	
		'komponen_gaji_id'=>my_type_data_int( $_POST['komponen_gaji_id'] ),	
		'formula'=>my_type_data_str( $_POST['formula'] ),
		'kena_pajak'=>my_type_data_str( $_POST['kena_pajak'] ),	
		'komponen_pajak_1'=>my_type_data_int( $_POST['komponen_pajak_1'] ),	
		'komponen_pajak_2'=>my_type_data_int( $_POST['komponen_pajak_2'] ),	
	);
	
	if($id > 0){
		return my_update_record('yearly_komponen' ,'yearly_komponen_id' , $id , $datas);
	}
	return my_insert_record('yearly_komponen' , $datas);
} 

function form_komponen_validate($yearly_income_id,$yearly_group_id , $id =0){
	$errsubmit = false;
	$err = array();
	 
	$nama =  trim($_POST["nama_komponen"]); 
	$query="SELECT yearly_komponen_id FROM yearly_komponen 
		WHERE nama_komponen='".$nama.
		"' AND yearly_group_id=".$yearly_group_id.
		" AND yearly_komponen_id<>".$id ; 
	if (my_num_rows( my_query($query)) >0){
		$errsubmit = true;
		$err[] = "Nama sudah ada";	
	}
    
	if( $errsubmit){
		return $err;
	}
	return $errsubmit;
}

function delete_komponen($id){
	$query = "DELETE FROM yearly_komponen WHERE yearly_komponen_id ={$id} ";
	return my_query($query);
}	


function print_plain($yearly_income_id){
	
	$query = "
			SELECT b.code,b.label as uraian_judul,b.uraian_total,b.kategori,c.*   		
			FROM yearly_income a
			INNER JOIN yearly_group b ON b.yearly_income_id=a.yearly_income_id 
			INNER JOIN yearly_komponen c ON c.yearly_group_id=b.yearly_group_id 
			WHERE a.yearly_income_id={$yearly_income_id} 
			ORDER BY b.code, c.yearly_komponen_id
		";
	$result = my_query($query ); 
	$datas = array(); 
	$datas[] = array(
		 'k1'=>array("No." ,5 ,STR_PAD_BOTH),
		 'k2'=>array("Uraian" ,30,STR_PAD_RIGHT),
		 'k3'=>array("Nilai" ,10,STR_PAD_LEFT),
		 'k4'=>array("Formula" ,45,STR_PAD_RIGHT),
		 'k5'=>array("Pajak" ,10,STR_PAD_RIGHT),
	); 						
	$no=0;
	$code=$uraian_total=$kategori="";
	while($ey = my_fetch_array($result)){
		if( $ey['model_entry']==1 ){ //Gaji Pokok
			$formula='[GAPOK]' ;
		}elseif( $ey['model_entry']==2 ){ //Komponen Gaji
			$komponen_gajis=my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$ey['komponen_gaji_id']);
			$formula='['.$komponen_gajis['nama_komponen_gaji'].']' ;			
		}elseif( $ey['model_entry']==3 ){ //Nilai Pajak
			$formula='[PAJAK]' ;		
		}elseif( $ey['model_entry']==4 ){ //Upload
			$formula='[UPLOAD]' ;
		}elseif( $ey['model_entry']==5 ){ //Selisih Pembulatan
			$formula='[SELISIH]' ;
		}elseif( $ey['model_entry']==6 ){ //Total
			$formula='[TOTAL]' ;	
		}	
		$formula.=$ey['formula'] ;
		
		if($code <>  $ey['code']){
			if($code <> " "){
				if($uraian_total<>''){ 
					$no++;
					$datas[] = array(
						'k1'=>array(" " ,5 ,STR_PAD_BOTH),
						'k2'=>array($uraian_total ,30,STR_PAD_RIGHT),
						'k3'=>array($kategori."XXXXX" ,10,STR_PAD_LEFT),
						'k4'=>array(" " ,45,STR_PAD_RIGHT),	
						'k5'=>array(" " ,10,STR_PAD_RIGHT),							
					); 					
					
				}	
			}
			$uraian_total= $ey['uraian_total'] ;
			if( $ey['nama_komponen'] =='' ){ //DETAIL
				$no++;
				$datas[] = array(
					'k1'=>array($ey['code'] ,5 ,STR_PAD_BOTH),
					'k2'=>array($ey['uraian_judul'] ,30,STR_PAD_RIGHT),
					'k3'=>array($ey[kategori]."XXXXX" ,10,STR_PAD_LEFT),
					'k4'=>array($formula ,45,STR_PAD_RIGHT),
					'k5'=>array(" " ,10,STR_PAD_RIGHT),									
				); 					
			}else{ //HEADER
				$no++;
				$datas[] = array(
					'k1'=>array($ey['code'] ,5 ,STR_PAD_BOTH),
					'k2'=>array($ey['uraian_judul'] ,30,STR_PAD_RIGHT),
					'k3'=>array(" " ,10,STR_PAD_LEFT),
					'k4'=>array(" " ,45,STR_PAD_RIGHT),	
					'k5'=>array(" " ,10,STR_PAD_RIGHT),									
				); 
			}
			$code=$ey['code'] ;
			$kategori=$ey['kategori'] ;
		}
		if( $ey['nama_komponen'] <>'' ){
			$no++;
				$no++;
				$datas[] = array(
					 'k1'=>array(" " ,5 ,STR_PAD_BOTH),
					 'k2'=>array($ey['nama_komponen'] ,30,STR_PAD_RIGHT),
					 'k3'=>array("XXXXX" ,10,STR_PAD_LEFT),
					 'k4'=>array($formula ,45,STR_PAD_RIGHT),	
					 'k5'=>array($ey['kena_pajak'] ,10,STR_PAD_RIGHT),				
				); 	
		}		
	}
	if($uraian_total<>''){ 
		//'Sub Total','Total'	
		$no++;
		$datas[] = array(
			 'k1'=>array(" " ,5 ,STR_PAD_BOTH),
			 'k2'=>array( $uraian_total ,30,STR_PAD_LEFT),
			 'k3'=>array($kategori."XXXXX" ,10,STR_PAD_LEFT),
			 'k4'=>array(" " ,45,STR_PAD_RIGHT),
			 'k5'=>array(" " ,10,STR_PAD_RIGHT),				
		); 	
	}	
	$view = 	str_pad("CETAK YEARLY INCOME",100," ",STR_PAD_BOTH);
	return $view ."\n"."\n".set_txt_report($datas);
}